{% extends "base.html" %}
{% block title %}Start{% endblock %}
{% block content %}
<div class="content">
    <p class="content-note1">修改密码<span class="content-note2"> (标注为*为必填项)</span></p>
    <div style="clear:both"></div>
    <form class="form-table" action="{% url 'changepwd' %}" method="post">

        <div class="form-list">
            <span>*用户名</span><input {% if user_pwd_modify_form.errors.usernum1 %}class="input-error" {% endif %}
                id="usernum1" type="username" name="usernum1" value="{{ usernum1 }}" />
        </div>

        <div class="form-list">
            <span>*新密码</span><input {% if user_pwd_modify_form.errors.pwd1 %}class="input-error" {% endif %} id="pwd1"
                type="password" name="pwd1" value="{{ pwd1 }}" />
        </div>
        <div class="form-list">
            <span>*确认密码</span><input {% if user_pwd_modify_form.errors.pwd2 %}class="input-error" {% endif %} id="pwd2"
                type="password" name="pwd2" value="{{ pwd2 }}" />
        </div>
        {% if msg %}
        <div class="error">{{ msg }}</div>
        {% endif %}
        <div style="clear:both"></div>
        <div class="form-list">
            <input id="pwd_reset" class="form-button" type="submit" value="保存" />
        </div>
        <div class="form-list">
            <button class="form-button" type="button" onclick="btn_cancel()">取消</button>
        </div>
        {% csrf_token %}
    </form>
</div>
{% endblock %}
{% block custome_js %}
<script>
    var pwd_reset = document.getElementById("pwd_reset");
    pwd_reset.onclick = function () {
        var pwd1 = document.getElementById("pwd1").value;
        var pwd2 = document.getElementById("pwd2").value;
        if (pwd1 === pwd2 && !!pwd1) {
            alert("密码修改成功，请重新登录！");
        }
    };

    function btn_cancel() {
        location.href = "{% url 'login' %}";
    }
</script>
{% endblock %}